fun main(args : Array<String>){
	var person1 = Person("Leo")
	person1.eat()
	println("lastName=${person1.lastName}")
	
	println("======================")
	val _out = Outer()
	val number = Outer.In().xx()
	println(number)
	
	println("---------------------")
	val demo = MyOuter().Inner().xx()
	println(demo)
	val demo1 = MyOuter().Inner().innerTest()
	println("************************")
	var test = Test()
	
	test.setInterFace(object:TestInterFace{
		override fun test(){
			println("哈哈哈我来也")
		}
	})
	

}

//空类
class Empty

class MyTest private constructor(){
	
}
//
class Person constructor(var firstName:String){
	
	//生成对象的时候调用
	init{
		println("I love China")
		println("xx=$firstName")
	}
	
	//次构造函数
	constructor (age:Int,firstName:String):this(firstName){
	
	}
	
	
	lateinit var test:Test
	var a:Int ? =9
	var b:Int = 3
	val c:Int = 8 
	
	var lastName:String = "Zhang"
		get() = field.toUpperCase()
		set
	
	var num:Int = 100
		get() = field
		set(value){
			if(value<10){field=value}
			else{field=-1}
		}
		
	var height:Float = 123.2F
		private set
	
	fun eat(){println("$lastName $firstName is eating")}
}

open class Base{
	open fun drive(){}
}

abstract class Car:Base(){
	
	override abstract fun drive()

}

//嵌套
class Outer{
	private val num:Int = 1
	class In{
		fun xx() = 2
	}
}

//内部类
class MyOuter{
	private val num:Int = 1
	var p = "Out Member"
	inner class Inner {
		fun xx() = num
		fun innerTest(){
			var _out = this@MyOuter//获取外部类的成员变量
			println("内部类获取外部类的成员" + _out.p)
		}
		
	}
}

//匿名内部类
class Test {
	var p = "Member"
	
	fun setInterFace(test:TestInterFace){
		test.test()
	}
}

//定义接口 
interface TestInterFace{
	fun test()
}

//abstract.  抽象类
//final.   无法继承。默认就是final
//enum.   枚举类
//open
//annotation.   注解类

//private public protected 
//internal.   同一个模块中可见


